package com.sh.data.engine.domain.api.model.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

@Data
//@ApiModel
public class DataApiRegisterDomain {

    //    @NotNull
//    @Pattern(regexp = "^(GET|POST)$", message = "请求方式必须为GET或POST")
//    @ApiModelProperty(value = "请求方式", required = true, notes = "GET POST")
    private String httpRequestMethod;

    // http url
//    @NotNull
//    @ApiModelProperty(value = "路径", required = true)
//    @Pattern(regexp = "^https?://.*", message = "url非法")
    private String url;

    // 认证参数
//    @Valid
//    @NotNull
//    @ApiModelProperty(value = "请求认证", required = true)
    private ApiHttpAuthDomain apiHttpAuth;

    // 请求头
//    @Valid
//    @NotNull
//    @ApiModelProperty(value = "请求头")
    private ApiHttpRequestHeaderDomain apiHttpRequestHeader;

    // 请求体
//    @Valid
//    @NotNull
//    @ApiModelProperty(value = "请求体")
    private ApiHttpRequestBodyDomain apiHttpRequestBody;

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class ApiHttpAuthDomain {
        // 认证方式    noauth, basic, sign, token
//        @ApiModelProperty(value = "认证方式", notes = "noauth, basic, sign, token, jar", required = true)
//        @NotNull
        private String authType;

        // basic
//        @ApiModelProperty(value = "basic认证")
        private String authUsername;

        //        @ApiModelProperty(value = "basic认证")
        private String authPassword;

        // sign
//        @ApiModelProperty(value = "sign")
        private String accessKey;

        //        @ApiModelProperty(value = "sign")
        private String accessSecret;

        // token
//        @ApiModelProperty(value = "token")
        private String accessToken;

        //        @ApiModelProperty(value = "jar缓存key")
        private String advancedCacheKey;

        // 资源名字
//        @ApiModelProperty(value = "jar 文件名")
        private String advancedFileName;
        // 资源路径
//        @ApiModelProperty(value = "jar 自定义认证")
        private String advancedFilePath;

        //        @ApiModelProperty(value = "jar包class")
        private String advanceClassReference;

        //        @ApiModelProperty(value = "jar包方法名")
        private String advanceMethodName;

        // 变量有效期
//        @ApiModelProperty(value = "有效期")
        private Date expires;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class ApiHttpRequestHeaderDomain {
        // 请求头列表
//        @ApiModelProperty(value = "请求头列表")
        private List<Header> params;

        @Data
//        @ApiModel("请求头")
        @NoArgsConstructor
        @AllArgsConstructor
        public static class Header {
            // 消息头名称
//            @NotNull
//            @ApiModelProperty(value = "header name", notes = "x-id", required = true)
            private String name;
            // 具体值
//            @NotNull
//            @ApiModelProperty(value = "header value", notes = "123", required = true)
            private String value;
        }
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class ApiHttpRequestBodyDomain {

        //        @NotNull
//        @ApiModelProperty(value = "请求体传参方式", notes = "json or form", required = true)
        private String contentType;
        // 请求体
//        @ApiModelProperty(value = "json")
        private String body;

        // url参数
//        @ApiModelProperty(value = "form参数")
        private List<FormDomain> formParams;

        @Data
        @NoArgsConstructor
        @AllArgsConstructor
        public static class FormDomain {

            /**
             * 参数类型 0-输入参数 1-返回参数
             */
//            @ApiModelProperty(value = "参数类型", required = true)
//            @NotNull
            private Integer paramType;

            /**
             * 参数名称
             */
//            @NotNull
//            @ApiModelProperty(value = "参数名称", required = true)
            private String paramName;

            /**
             * 参数位置 query head body
             */
//            @NotNull
//            @ApiModelProperty(value = "参数位置", notes = "query", required = true)
            private String paramPosition = "query";

            /**
             * 参数数据类型
             */
//            @NotNull
//            @ApiModelProperty(value = "参数数据类型", notes = "STRING", required = true)
            private String paramDataType;

            /**
             * 参数值
             */
//            @NotNull
//            @ApiModelProperty(value = "参数值", notes = "123", required = true)
            private String paramValue;

            /**
             * 描述
             */
//            @ApiModelProperty(value = "参数描述")
            private String paramDesc;

            /**
             * 返回参数取值表达式
             */
//            @ApiModelProperty(value = "参数描述")
            private String paramExpression;

            /**
             * 参数属性 0-无(纯输入值) 1-pageNo 2-pageSize
             */
//            @ApiModelProperty(value = "分页参数默认填写0", required = true)
//            @NotNull
            private Integer paramAttribute = 0;
        }
    }
}
